package com.chanel.iamframework.core.dao;

import com.chanel.iamframework.core.domain.Role;

public interface RoleDAO {
	
	/**
	 * Persist Role entity
	 * @param role entity
	 * @return The number of rows affected by the insert
	 */
	int createRole(Role role);
	
	/**
	 * Get Role by Identity
	 * @param roleId entity
	 * @return Role entity
	 */
	Role getRole(Long roleId);
	
	/**
	 * Update Role entity
	 * @param role entity
	 * @return The number of rows affected by the insert
	 */
	int updateRole(Role role);
    
	/**
	 * Delete Role entity
	 * @param roleId Identity
	 * @return The number of rows affected by the insert
	 */
	int deleteRole(Long roleId);

	/**
	 * Load Groups by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Group}
	 */
	Role loadGroups(Long roleId);
    
	/**
	 * Load Application by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	Role loadApplications(Long roleId);

	/**
	 * Load User by RoleId into the returned {@link Role} instance.
	 * @param roleId identity
	 * @return {@link Role} instance with list of {@link com.chanel.iamframework.core.domain.User}
	 */
	Role loadUsers(Long roleId);
	
	/**
	 * Add Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	int addGroup(Long groupId, Long roleId);

	/**
	 * Delete Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	int deleteGroup(Long groupId, Long roleId);
}